package com.zyw.boot.tool;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.stream.Collectors;

public class QuoteReplacer {
    public static void main(String[] args) {

        Path inputPath = Paths.get("D:\\command_db\\main.sql");
        Path outputPath = Paths.get("D:\\command_db\\main1.sql");

        try {
            // 读取文件所有行
            List<String> lines = Files.readAllLines(inputPath);

            // 处理每一行内容
            List<String> processedLines = lines.stream()
                    .map(line -> line.replaceAll("\\bDEFAULT\\s+'([^']*)'", "DEFAULT('$1')"))
                    .collect(Collectors.toList());

            // 写入新文件
            Files.write(outputPath, processedLines);
            System.out.println("Processing completed successfully!");

        } catch (IOException e) {
            System.err.println("Error processing file: " + e.getMessage());
        }
    }
}